let array=[];
function fn(){
    
    // for..of 和for ..in 的区别
    for(let item of arguments){
        console.log('of',item)
        array.push(item)
    }
    for(let item in arguments){
        console.log('in',item)
    }
}

fn.apply(array,[12,3,4,1])

function fn1(){
    console.log(arguments);
    console.log(this)
}
const newFn=fn1.bind(document)
console.log(newFn(12,3,4))
var fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];

/**
 * Array filters items based on search criteria (query)
 */
function filterItems(query) {
  return fruits.filter(function(el) {
      return el.toLowerCase().indexOf(query.toLowerCase()) > -1;
  })
}

console.log(filterItems('ap')); // ['apple', 'grapes']
console.log(filterItems('an')); // ['banana', 'mango', 'orange']

const kvArray=[{key: 1, value: 10}, 
    {key: 2, value: 20}, 
    {key: 3, value: 30}];

const reformattedArray=kvArray.map((obj)=>{
    const resultArray={};
    resultArray[obj.key]=obj.value;
    return resultArray
})
console.log(reformattedArray)
const problem = [1, 2, 3, [4, 5, [6, 7], 8, 9]];
console.log(flaten(problem));
function flaten(problem){
    const result=[];
    problem.forEach(item=>{
        if(Array.isArray(item)){
            result.push(...flaten(item))
        }else{
            result.push(item)
        }
    })
    return result;
}

function mapFn(){
    const url='https://www.bilibili.com/video/BV1hJ411g7VS?p=';
    for(let i=1;i<=30;i++){
        console.log(url+i)
    }
    /*
    
    Apple computer can't download this page, and many attempts fail. The video downloaded from apple mobile phone can't be clearly watched on the computer. I hope it can be downloaded from apple computer, so that users can have a better experience
    */
}
mapFn()